﻿using System;
using System.Runtime.Serialization;
using MultiViewer.Network;
using System.Windows.Input;
using System.Windows;

namespace MultiViewer.Display
{
    [DataContract]
    public enum MouseButton
    {
        [EnumMemberAttribute]
        LeftDown,
        [EnumMemberAttribute]
        LeftUp,
        [EnumMemberAttribute]
        RightDown,
        [EnumMemberAttribute]
        RightUp
    }
    [DataContract]
    public class InitDisplayRequest : Message
    {
        private int width, height;
        private int gridWidth, gridHeight;
        private bool fullscreen;
        private int cursorWidth,cursorHeight;
        private int glassWidth, glassHeight;
        private bool simulateMouseEvents;
        private bool glass;
        private double zoom;

        public InitDisplayRequest(MasterConfigurationSection config)
        {
            gridWidth = config.Width;
            gridHeight = config.Height;
            this.width = config.Display.Width;
            this.height = config.Display.Height;
            this.fullscreen = config.Display.Fullscreen;
            this.simulateMouseEvents = config.Display.SimulateMouseEvents;
            this.Zoom = config.Display.zoom;
            this.cursorWidth = config.Display.CursorWidth;
            this.cursorHeight = config.Display.CursorHeight;
            this.glassWidth = config.Display.GlassWidth;
            this.glassHeight = config.Display.GlassHeight;
            this.glass = config.Display.Glass;
        }

        /// <summary>Gets or sets display width in pixels</summary>
        [DataMember]
        public int Width
        {
            get { return width; }
            set { width = value; }
        }

        /// <summary>Gets or sets display height in pixels</summary>
        [DataMember]
        public int Height
        {
            get { return height; }
            set { height = value; }
        }

        /// <summary>Gets or sets display grid width (in displays)</summary>
        [DataMember]
        public int GridWidth
        {
            get { return gridWidth; }
            set { gridWidth = value; }
        }

        /// <summary>Gets or sets display grid height (in displays)</summary>
        [DataMember]
        public int GridHeight
        {
            get { return gridHeight; }
            set { gridHeight = value; }
        }

        [DataMember]
        public bool Fullscreen
        {
            get { return fullscreen; }
            set { fullscreen = value; }
        }
        [DataMember]
        public bool SimulateMouseEvents
        {
            get { return simulateMouseEvents; }
            set { simulateMouseEvents = value; }
        }
        [DataMember]
        public double Zoom
        {
            get { return zoom; }
            set { zoom = value; }
        }
        [DataMember]
        public bool Glass
        {
            get { return glass; }
            set { glass = value; }
        }
        [DataMember]
        public int CursorWidth
        {
            get { return cursorWidth; }
            set { cursorWidth = value; }
        }
        [DataMember]
        public int CursorHeight
        {
            get { return cursorHeight; }
            set { cursorHeight = value; }
        }
        [DataMember]
        public int GlassWidth
        {
            get { return glassWidth; }
            set { glassWidth = value; }
        }
        [DataMember]
        public int GlassHeight
        {
            get { return glassHeight; }
            set { glassHeight = value; }
        }
    }

    [DataContract]
    public class ShutdownRequest : Message
    {
        // No members here
    }

    [DataContract]
    public class MouseNotification : Message
    {
        private double x,y;

        [DataMember]
        public double X
        {
            get { return x; }
            set { x = value; }
        }

        [DataMember]
        public double Y
        {
            get { return y; }
            set { y = value; }
        }

        public Point Position
        {
            get { return new Point(x, y); }
            set
            {
                x = value.X;
                y = value.Y;
            }
        }
    }


    [DataContract]
    public class MouseClickNotification : MouseNotification
    {
        private MouseButton button;

        [DataMember]
        public MouseButton Button
        {
            get { return button; }
            set { button = value; }
        }
    }

    [DataContract]
    public class MouseWheelNotification : MouseNotification
    {
        private int delta;

        [DataMember]
        public int Delta
        {
            get { return delta; }
            set { delta = value; }
        }
    }
}
